<!--
 * @Author: xjt
 * @Date: 2021-06-26 11:16:01
 * @LastEditTime: 2021-06-26 13:55:23
 * @Description: 隔离人员信息
 * @LastEditors: xjt
-->
<template>
  <div class="basic-form">
    <el-form ref="form" label-position="right" class="form-wrap preview-form"  :model="formData">
      <div class="card-title full info-subtitle">基础信息</div>
      <el-form-item label="隔离点名称" prop="hotelName"><span>{{formData.hotelName}}</span></el-form-item>
      <el-form-item label="旅客入住来源" prop="dataSource">{{formData.dataSource | dict("data_source")}}</el-form-item>
      <el-form-item label="批次号" prop="batchNum">{{formData.batchNum}}</el-form-item>
      <el-form-item label="姓名" prop="name">{{formData.name}}</el-form-item>
      <el-form-item label="性别" prop="gender">{{formData.gender | dict("gender") }}</el-form-item>
      <el-form-item label="年龄" prop="age">{{formData.age && `${formData.age}（岁）`}}</el-form-item>
      <el-form-item
        label="人员类型"
        prop="personClassify"
      >{{formData.personClassify|dict("person_classify")}}</el-form-item>
      <el-form-item label="国籍或地区" prop="webCustomAddress">{{formData.webCustomAddress}}</el-form-item>
      <el-form-item label="证件类型" prop="cardType">{{formData.cardType | dict("card_type")}}</el-form-item>
      <el-form-item label="证件号码" prop="cardId">{{formData.cardId}}</el-form-item>
      <!-- <el-form-item label="护照" prop="passportNum">{{formData.passportNum}}</el-form-item> -->
      <el-form-item label="电话号码" prop="telPhone">{{formData.telPhone}}</el-form-item>
      <el-form-item label="目的地" prop="webCustomAddressTo">{{formData.webCustomAddressTo}}</el-form-item>
      <el-form-item label="目的地详细地址" prop="destinationAddr">{{formData.destinationAddr}}</el-form-item>
      <el-form-item label="来自所在国或地区" prop="comeCountryCity">{{formData.comeCountryCity}}</el-form-item>
      <el-form-item label="入境方式" prop="entryWay">{{formData.entryWay| dict("entry_way")}}</el-form-item>
      <el-form-item label="入境时间" prop="entryTime">{{formData.entryTime}}</el-form-item>
      <!-- <el-form-item
        label="核酸检验情况"
        prop="nucleinTestCase"
      >{{formData.nucleinTestCase | dict("nuclein_test_case")}}</el-form-item>
      <el-form-item
        label="是否在校留学生"
        prop="isOverStudent"
      >{{formData.isOverStudent | dict("is_valid")}}</el-form-item>
      <el-form-item label="是否有境外旅居史" prop="isYjwLjs">{{formData.isYjwLjs| dict("is_valid")}}</el-form-item>
      <el-form-item label="是否机组人员" prop="isAircrew">{{formData.isAircrew| dict("is_valid")}}</el-form-item>
      <el-form-item label="是否入境奔丧人员" prop="isMourning">{{formData.isMourning| dict("is_valid")}}</el-form-item>
      <el-form-item label="是否孕妇" prop="isGravida">{{formData.isGravida| dict("is_valid")}}</el-form-item>
      <el-form-item
        label="是否有明显的身体疾病"
        prop="isBodyDisease"
      >{{formData.isBodyDisease| dict("is_valid")}}</el-form-item>
      <el-form-item
        label="是否有基础疾病"
        prop="isBasicDisease"
      >{{formData.isBasicDisease| dict("is_valid")}}</el-form-item>
      <el-form-item
        label="是否属于前科人员"
        prop="isCriminalPerson"
      >{{formData.isCriminalPerson| dict("is_valid")}}</el-form-item>
      <el-form-item
        label="是否存在精神异常或者心理异常"
        prop="isSpiritHeartExce"
      >{{formData.isSpiritHeartExce| dict("is_valid")}}</el-form-item>-->
      <el-form-item label="风险等级" prop="riskLevel">{{formData.riskLevel|dict("risk_level")}}</el-form-item>
      <el-form-item class="full" label="备注" prop="remark">{{formData.remark}}</el-form-item>
      <div class="card-title full">紧急联系人</div>
      <el-form-item label="紧急联系人关系" prop="emergencyContactType">{{formData.emergencyContactType}}</el-form-item>
      <el-form-item label="紧急联系人姓名" prop="emergencyContactName">{{formData.emergencyContactName}}</el-form-item>
      <el-form-item label="紧急联系人电话" prop="emergencyContactPhone">{{formData.emergencyContactPhone}}</el-form-item>
      <!-- <div class="card-title full">信息核实情况</div>
      <el-form-item label="核验是否通过" prop="verifyResult">{{formData.verifyResult| dict("is_valid")}}</el-form-item>
      <el-form-item label="核验人" prop="verifyName">{{formData.verifyName}}</el-form-item>
      <el-form-item label="核验结果说明" prop="verifyRemark">{{formData.verifyRemark}}</el-form-item>-->
      <div v-show="this.formData.personId" class="card-title full">证件（正反面拍照上传）</div>
      <p v-show="!this.formData.personId">暂无数据</p>
      <imageTpl :id="this.formData.personId" v-show="this.formData.personId"></imageTpl>
      <!-- <div class="card-title full">行程列表</div>
      <div class="full">
        <el-table :data="formData.routes" stripe style="width: 100%">
          <el-table-column type="index" width="50"></el-table-column>
          <el-table-column prop="webCustomAddressOut" label="出发地" width="180">
            <template
              slot-scope="scope"
            >{{getAddr(scope.row.outAddrProvince, scope.row.outAddrCity)}}</template>
          </el-table-column>
          <el-table-column prop="outDate" label="出发时间" width="180"></el-table-column>
          <el-table-column prop="webCustomAddressGet" label="到达地">
            <template
              slot-scope="scope"
            >{{getAddr(scope.row.getAddrProvince, scope.row.getAddrCity)}}</template>
          </el-table-column>
          <el-table-column prop="getDate" label="到达时间"></el-table-column>
          <el-table-column prop="tripTrafficWay" label="出行交通方式">
            <template slot-scope="scope">{{scope.row. tripTrafficWay | dict("trip_traffic_way")}}</template>
          </el-table-column>
          <el-table-column prop="flightNumber" label="出行交通方式排号登记"></el-table-column>
        </el-table>
      </div>-->
    </el-form>
  </div>
</template>

<script>
import { getMemberInfo, getProvinceCity } from "../api/info";
import imageTpl from "./image-tpl.vue";
import { mixinsId } from "../mixin/mixinId";
import { getContact} from "@/views/yq-personnel/api/check.js";
export default {
  name: "userInfo",
  mixins: [mixinsId],
  components: {
    imageTpl,
  },
  props: {
    hotelName: String,
  },
  inject: ["personId"],
  data() {
    return {
      formData: {},
    };
  },
  mounted() {
    this.queryData();
    this.$bus.$on("previewInfoOpen", () => {
      this.queryData();
      
    });
  },
  methods: {
    async queryData() {
      let res = await getMemberInfo(this.personId());
      this.formData = res.data.data.jdglPersonInfo;
      this.formData.hotelName = sessionStorage.getItem("hotelName");
       this._getContact(this.personId())
    },
    async getCity() {
      let res = await getProvinceCity();
      return res.data.data;
    },
    getAddr(Province, city) {
      if (!Province) return;
      let province_city_list = JSON.parse(
        localStorage.getItem("province_city_list")
      );
      province_city_list || (province_city_list = this.getCity());
      let str = "";
      str = this.getCitys(Province, city, province_city_list);
      return str;
    },
    getCitys(Province, city, list) {
      let str = "";
      for (let i = 0; i < list.length; i++) {
        const ele = list[i];
        if (ele.id === "000000") {
          for (const item of ele.children) {
            if (item.id == Province) {
              str = item.areaName;
              if (item.children.length && city) {
                for (const v of item.children) {
                  if (v.id == city) {
                    str += " | " + v.areaName;
                    return str;
                  }
                }
              }
            }
          }
        }
      }
      return str;
    },
    _getContact(pid) {
      // 获取联系人
      getContact(pid).then((res) => {
        console.log(res);
        let data = res.data.data;
        this.formData.emergencyContactType = data.emergencyContact1Type;
        this.formData.emergencyContactPhone = data.emergencyContact1Phone;
        this.formData.emergencyContactName = data.emergencyContact1Name;
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.userInfo{

}
</style>